var express = require('express');
var router = express.Router();
const { uploadFiles } = require("../utils/handleFiles");

router.post('/upload', function (req, res, next) {
    const upload = uploadFiles({
        path: "./public/temp",
        key: "file",
        size: 1000
    });
    upload(req, res, err => {
        if (err) {
            res.send({
                status: 0,
                message: "失败"
            })
        } else {
            res.send({
                status: 1,
                message: "成功",
                result: req.files[0].filename
            })
        }
    })
});


module.exports = router;
